package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDemo9 {
    public static void main(String[] args) {
        try (Connection conn=DBUtil.getConnection()){
            PreparedStatement ps=conn.prepareStatement("insert into user(username,password,nickname,age) values(?,?,?,?)");
            ps.setString(1,"张三");
            ps.setString(2,"123456");
            ps.setString(3,"三三");
            ps.setInt(4,20);
            int num = ps.executeUpdate();
            if(num>0){
                System.out.println("插入成功");
            }else{
                System.out.println("插入失败");
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
